package liangtWorkSpace;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName AppleTest
 * @Description : 功能说明
 * @Author : LiangT
 * @Date : 2020/4/14 19:15
 */
public class AppleTest {
    public static boolean isGreenApple(Apple apple){
        return "green".equals(apple.getColor());
    }
    public static boolean isWeightApple(Apple apple){
        return apple.getWeight() > 150;
    }
    public static List<Apple> filterApple(List<Apple> apples,Predicate<Apple> predicate){
        List<Apple> result = new ArrayList<>();

        for (Apple apple: apples){
            if (predicate.test(apple))
                result.add(apple);
        }
        return result;
    }
}
